<?php

class Cript{

//**********************************************************************
//*
//* METODO PARA DESCRIPTOGRAFAR A SENHA
//*
//**********************************************************************
	function Descriptografa($pEnt){

		$psai = "";
		if ($pEnt == ""){
			exit;
		}

		$crip = ord(substr($pEnt, ((int)(strlen($pEnt)))-1, 1)) - 120;
		
		for ($ii=1; $ii <= (int)strlen($pEnt)-1; $ii++){
			$psai .= chr(ord(substr($pEnt, $ii-1, 1)) - $crip);
		}
		$this->Descriptografa = $psai;
		return $this->Descriptografa;
	}

//**********************************************************************
//*
//* METODO PARA CRIPTOGRAFAR A SENHA
//*
//**********************************************************************
	function Criptografa($senha){

		$crip = 0;
		$psai = "";
		if ($senha == ""){
			exit;
		}

   		$timestamp = mktime(date("H")-3, date("i"), date("s"));

		while ($crip == 0){
			$crip = substr(gmdate("H:i:s", $timestamp),7,1);
		}
	
		$psai = "";
		for ($ii=1; $ii <= (int)strlen($senha); $ii++){
			$psai .= chr(ord(substr($senha, $ii-1, 1)) + $crip);
		}
	 
		if ($psai == ""){
			$this->Criptografa = "Erro INT REG 51XE-3";
		}else{
			$this->Criptografa = $psai.chr($crip+120);
		}
		return $this->Criptografa;
	}
		
	
}


$Criptografia = new Cript;
?>
